package com.example.tse.rbyair.dialog;

import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.example.tse.rbyair.R;

public class CheckCallDialog extends DialogFragment {


    private TextView nomaldialogCancle;
    private TextView nomaldialogButton;
    private OnOkClickLitener onOkClickLitener;

    public void setOnOkClickLitener(OnOkClickLitener l) {
        onOkClickLitener = l;
    }

    public interface OnOkClickLitener {
        void OK();

        void Cancel();
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        final Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent_NoTitleBar);
        Window window = dialog.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        window.isFloating();
        WindowManager.LayoutParams wlp = window.getAttributes();
//        window.setWindowAnimations(R.style.dialogWindowAnim); //设置窗口弹出动画
        wlp.width = WindowManager.LayoutParams.WRAP_CONTENT;
        wlp.height = WindowManager.LayoutParams.WRAP_CONTENT;//DensityUtils
        wlp.dimAmount = 0.5f;// Range is from 1.0 for completely opaque to 0.0 for no* dim
        wlp.gravity = Gravity.CENTER;
        dialog.setCanceledOnTouchOutside(true);
        window.setAttributes(wlp);
        return dialog;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dialog_check_call, container);
        nomaldialogCancle = (TextView) view.findViewById(R.id.nomaldialog_cancle);
        nomaldialogButton = (TextView) view.findViewById(R.id.nomaldialog_button);
        nomaldialogButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onOkClickLitener.OK();
                dismiss();
            }
        });
        nomaldialogCancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onOkClickLitener.Cancel();
                dismiss();
            }
        });
        return view;
    }
}

